<!-- 用户管理 -->
<template>
    <div class="rightCenter">
        <div class="listTop">
            <div></div>
            <div class="listTopInpBox">
                <div class="listTopInpIco">
                    <i class="icon font_family icon-sousuo"></i>
                </div>
                <input class="listTopInp" type="text" v-model="searchVal" placeholder="搜索商品名称/订单编号">
            </div>
        </div>
        <ul class="listUl">
            <li class="listLi fristLI">
                <div class="listDiv listOne">
                    产品编号
                </div>
                <div class="listDiv listTwo">
                    产品名称
                </div>
                <div class="listDiv listThree">
                    产品价格
                </div>
                <div class="listDiv listFive">
                    有效日期
                </div>
                <div class="listDiv listSix">
                    产品状态
                </div>
                <div class="listDiv listSeven">
                    操作
                </div>
            </li>
            <li class="listLi dataLi" v-for="(item,index) in dataList" :class="{grayBack:index % 2 == 1}" :key="index">
                <div class="listDiv listOne">
                    {{item.id}}
                </div>
                <div class="listDiv listTwo">
                    {{item.pname}}
                </div>
                <div class="listDiv listThree">
                    {{item.price}}
                </div>
                <div class="listDiv listFour">
                    {{item.stime | baseDateFun}}-{{item.etime | baseDateFun}}
                </div>
                <div class="listDiv listFive">
                    {{item.prodstatus | prodstatusFun}}
                </div>
                <div class="listDiv listSeven">
                    <div class="look buttonBox" @click="loogClick(index)">
                        查 看
                    </div>
                </div>
            </li>
        </ul>
        <div class="paging">
            <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="pageNo" :page-sizes="[10, 20, 30, 40]"
                :page-size="pageSize" layout="total, sizes, prev, pager, next, jumper" :total="totalVal">
            </el-pagination>
        </div>
    </div>
</template>
<script>
import { mapActions } from "vuex";
import integralRequest from "../../assets/integral";
export default {
  data() {
    return {
      searchVal: "", //所搜
      dataList: [],
      pageNo: 1, //页码
      pageSize: 10, //每页条数
      totalVal: 0 //总数量
    };
  },
  filters: {
    prodstatusFun(val) {
      if (val) {
        if (val == "00") {
          return "在用";
        } else if (val == "01") {
          return "预约";
        } else if (val == "10") {
          return "停用";
        } else if (val == "20") {
          return "退订";
        } else if (val == "30") {
          return "怡宝装";
        } else if (val == "40") {
          return "升级中";
        }
      } else {
        return "暂无";
      }
    }
  },
  created: function() {
    let self = this;
    if (sessionStorage.getItem("TABLIST")) {
      let arr = JSON.parse(sessionStorage.getItem("TABLIST"));
      let routShow = false;
      for (let i = 0; i < arr.length; i++) {
        if (arr[i].name == "订单管理") {
          routShow = true;
        }
      }
      if (!routShow) {
        this.$router.push({
          path: "/login"
        });
        sessionStorage.clear();
        self.$message("暂无权限");
        return;
      }
    }else{
       this.$router.push({
          path: "/login"
        });
        sessionStorage.clear();
        self.$message("暂无权限");
        return;
    }
    self.searchVal = "";
    this.searchFun();
  },
  watch: {
    searchVal(val) {
      this.searchFun();
    }
  },
  mounted() {},
  methods: {
    //搜索
    async searchFun() {
      let self = this;
      let params = {
        id: self.searchVal,
        pname: self.searchVal,
        page: self.pageNo,
        size: self.pageSize
      };
      let getParams = `id=${params.id}&pname=${params.pname}&page=${
        params.page
      }&size=${params.size}`;
      let res = await integralRequest.getprodPage(getParams);
      if (res.statusCode == 200) {
        self.dataList = [];
        if (res.data) {
          if (res.data.records) {
            self.dataList = res.data.records;
          }
          self.totalVal = res.data.total * 1;
        }
      } else {
        self.$message(res.statusMessage);
        self.dataList = [];
      }
    },
    //分页 - 每页条数
    handleSizeChange(val) {
      this.pageSize = val;
      this.searchFun();
    },
    //分页 - 页数
    handleCurrentChange(val) {
      this.pageNo = val;
      this.searchFun();
    },
    //查看
    loogClick(index) {
      this.$router.push({
        path: `/home/orderForm/details?id=${this.dataList[index].id}`
      });
    }
  }
};
</script>
<style scoped="">
.listOne {
  width: 15%;
}

.listTwo {
  width: 15%;
}

.listThree {
  width: 15%;
}

.listFour {
  width: 15%;
}

.listFive {
  width: 15%;
}

.listSix {
  width: 15%;
}

.listSeven {
  width: 10%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.look {
  background: #279de2;
}
</style>